﻿function ilanListesiGetir() {
    var ilanMetni = "";
    ajaxCalistir({}, "mainFuncs.aspx/ilanMetniGetir", function (data) {
        $('#bannerBaslik').html(data.d.replace("\n", "<br/>"))
        ekranAc();
        ilanGetir();
    });
}
function IlanBul() {
    $('#divIlanlar li').removeHighlight();
    var src = $('#txtIlanBul').val();
    $('#divIlanlar li').highlight(src);
}
function ilanGetir() {
    var ilanMetni = "";
    ajaxCalistir({}, "mainFuncs.aspx/ilanListele", function (data) {
        $('#divIlanlar li').remove();
        if (data.d != null) {
            $.each(data.d, function (k, v) {
                var ht = '<li class="triangle-isosceles">' + v.ilanMetni + '</li>';
                $('#ilanul').append(ht);
                ekranAc();
            });
        }

        ekranAc();
    });
}
function CreateNewLikeButton(url, container) {
    var elem = $(document.createElement("fb:like"));
    elem.attr("href", url);
    elem.attr("data-send", false);
    //    elem.attr("width", "500px");
    //    elem.attr("height", "100px");
    //    elem.attr("float", "left");
    $('#' + container).empty().append(elem);
    FB.XFBML.parse($('#' + container).get(0));
}
function CreateNewLikeButton2(container) {
    //    var elem = $(document.createElement("fb:like"));
    //    elem.attr("href", url);
    //    elem.attr("data-send", true);
    //    //    elem.attr("width", "500px");
    //    //    elem.attr("height", "100px");
    //    //    elem.attr("float", "left");
    //    $('div#' + container).empty().append(elem);
    FB.XFBML.parse($('#' + container).get(0));
}
function twitterbuttonYarat() {
    $('.twitter-share-button').each(function (k, v) {
        var tweet_button = new twttr.TweetButton($(this).get(0));
        tweet_button.render();
    });
}
function twttrr() {
    !function (d, s, id) {
        var js, fjs = d.getElementsByTagName(s)[0];
        if (!d.getElementById(id)) {
            js = d.createElement(s); js.id = id;
            js.src = "//platform.twitter.com/widgets.js";
            fjs.parentNode.insertBefore(js, fjs);
        }
    }
(document, "script", "twitter-wjs");

}
function istatistikGetir() {
    ajaxCalistir({}, "mainFuncs.aspx/onlineKullaniciSayisi", function (data) {
        $('#counter').html('');
        $('#counter').append('<div>Aktif Kullanıcı : ' + data.d.aktif + '</div>');
        $('#counter').append('<div>Toplam Kullanıcı : ' + data.d.toplam + '</div>');
        $('#counter').append('<div>Ulaşabildiğimiz Kullanıcı  : ' + data.d.sosyal + '</div>');

    });

}
function meslekGetir() {

    ajaxCalistir({}, "iletisimFuncs.aspx/meslekGrubuGetir", function (data) {
        if (data.d != null) {
            $.each(data.d, function (key, value) {

                var ht = '<div style="float:left;width:100%"> <input type="checkbox"  id="chkMeslek' + value.id + '"  name="chkMeslek" value="' + value.id + '" /> ' + value.ad + '</div>';
                $('#AnaSayfaSol').append(ht);
            });
        }
    });
}
var ekUploader = null;
var ekler = "";
function createEkUploader() {
    ekler = "";
    $('#btnEkSec').unbind('click');

    if (ekUploader == null) {
        ekUploader = new plupload.Uploader({
            runtimes: 'gears,html5,flash,silverlight,browserplus',
            browse_button: 'btnEkSec',
            container: 'divEkYukleContainer',
            max_file_size: '500mb',
            url: 'ek.ashx',
            unique_names:true,
            multipart_params: {id:"G"},
            flash_swf_url: './Scripts/uploader/plupload.flash.swf',
            silverlight_xap_url: './Scripts/uploader/plupload.silverlight.xap',
            filters: [
				{ title: "Dosyalar", extensions: "*" },
			]
        });
    }
    

    ekUploader.init();
    ekUploader.bind('FilesAdded', function (up, files) {
        $.each(files, function (i, file) {
         //  $('#filelistEk').html("");
            $('#filelistEk').append(
					'<div class="EkAdded" id="' + file.id + '">' +
					file.name + ' (' + plupload.formatSize(file.size) + ') <b></b>' +
				'</div>');
        });

        up.refresh(); // Reposition Flash/Silverlight
        if ($(".EkAdded").length > 0) {
            ekUploader.start();
            e.preventDefault();
        } else {
            mesajVer("Önce Dosya Seçmelisiniz.");
        }
    });

    ekUploader.bind('BeforeUpload', function (u, f) {
//        auth = "<% = Request.Cookies[FormsAuthentication.FormsCookieName]==null ? string.Empty : Request.Cookies[FormsAuthentication.FormsCookieName].Value %>";
//        ASPSESSID = "<%= Session.SessionID %>";
       u.settings['multipart_params'] = {id:"G"};
    });

    ekUploader.bind('UploadProgress', function (up, file) {
        $('#' + file.id + " b").html(file.percent + "%");
    });

    ekUploader.bind('Error', function (up, err) {
        $('#divEkYukleContainer').append("<div>Error: " + err.code +
					", Message: " + err.message +
					(err.file ? ", File: " + err.file.name : "") +
					"</div>"
				);

        up.refresh(); // Reposition Flash/Silverlight
    });

    ekUploader.bind('FileUploaded', function (up, file) {
        $('#' + file.id + " b").html("100%");
        ekler = ekler+ file.target_name+",";
        //yuklenenProgram = file.name;
    });
}
function temizle() {
    $('#txtAd').val('');
     $('#txtSoyad').val('');
     $('#txtEposta').val('');
    $('#txtKonu').val('');
    $('#txtMesaj').val('');
    $('#filelistEk').html('');
}

function iletisimKaydet() {
    var ad = $('#txtAd').val();
    var soyad = $('#txtSoyad').val();
    var eposta = $('#txtEposta').val();
    var konu = $('#txtKonu').val();
    var mesaj = $('#txtMesaj').val();
    var meslekgruplari = "";
    var tip = $('input:radio[name=tip]:checked').val(); 
    
    $('input:checkbox:checked').each(function (k, v) {
        meslekgruplari = meslekgruplari + v.value + ',';
    });
    if (meslekgruplari == "") {
        mesajVer("Lütfen Meslek Grubu Seçiniz.");
        return;
    }
    if (!tip) {
        mesajVer("Mesaj Tipi Seçiniz.");
        return;
    }
    ajaxCalistir({ ad: ad, soyad: soyad, eposta: eposta, konu: konu, mesaj: mesaj,tip:tip, ekler: ekler,meslek:meslekgruplari,gelengiden:'G',gonder:'F' }, "iletisimFuncs.aspx/iletisimKaydet", function (data) {
        temizle();
        mesajVer("Mesajınız tarafımıza ulaştı.");
        ekranAc();
    });
}
function yazarListesiGetir() {
    var ilanMetni = "";
    ajaxCalistir({}, "mainFuncs.aspx/yazarGetir", function (data) {
        $('#bannerBaslik2').html('<div class="solyuzdeyuz fnt triangle-isoscelesy" style="text-align:justify;font-size:11px;width:98%" ><div class="solyuzdeyuz" style="text-align:center;margin-bottom:0px">YAZARLARIMIZ</div>Sizde Kendi Alanınızda Yeteneğinize Güveniyorsanız,  Bu Alandaki Düşüncelerinizi Ve Haberlerinizi Okuyucularımızla Paylaşmayı Düşünüyorsanız. Bizimle İletişime Geçerek Belirlediğiniz Bir Veya Birkaç Sosyal Medya Haber Sayfalamızdan  Bir Yönetim Paneli Alıp Kendi Okuyucu Kitlenizi Oluşturabilir, Sayfamızın Gönüllü Yazarı Veya Temsilcisi Olabilirsiniz.</div>');

        if (data.d != null) {
            for (var i = 0; i < data.d.length; i++) {
                var ht = '<div style="float:left;width:140px;overflow:hide;height:40px" class="uiListLight triangle-isosceles"><span style="width:60px;float:left;margin-top:5px"><img width="50" height="50"  src="http://' + window.location.host + '/yazarFoto/' + data.d[i].resim + '" alt="Yazar Resim" /></span><span class="fnt" style="width:40%;float:left;font-size:11px;margin-top:5px">' + data.d[i].username + '</span>' + '<span class="fnt" style="width:40%;float:left;font-size:11px">' + (data.d[i].meslek == null ? "" : data.d[i].meslek) + '</span></div>';

                $('#divIlanlar2').append(ht);
            }

        }

    });
}
$(document).ready(function () {

    if ($(window).width() > 1249) {
        $('#kontrolPaneli').width($('#fScreen').width() + 55);
        var t = (($(window).width() - 1250) / 2) + $('#AnaSayfaSol').width() + $('#haberAkis').width();
        var l = (($(window).width() - 1250) / 2) + 940 + "px";
        $('#sagScrl').css("left", t);
        var r = (($(window).width() - 1350) / 2) + 1250 + "px";
        $('#divBannerEkrani').css("left", r);
        //$('#counter').css("position", "fixed");

    } else {
        $('#kontrolPaneli').width($('#fScreen').width());

        $('#sagScrl').css("position", "static").css("margin-left", 0 + "px").css("float", "left").css("min-width", 300 + "px");
        //$('#counter').css("position", "static");
        $('#divBannerEkrani').css("left", $(window).width() - 20);

    }
    $('#btnBanner').html($('#btnBanner').text().replace(/(.)/g, "$1<br />"));
    $('#btnBanner2').html($('#btnBanner2').text().replace(/(.)/g, "$1<br />"));
    $("#bannerClik2").toggle(function () {
        $('#divIlanlar2').show();
        //$('#divIlanBul2').show();
        $('#bannerBaslik2').show();
        $('.baslikKategori').css("z-index", "0");
        var r = (($(window).width() - 1250) / 2) - 25;
        if ($(window).width() < 1250) {
            r = 0;
        }
        $("#divBannerEkrani2").animate({ "left": r, "width": 460 }, 1000);
        $('.bannerok2').html('<img  src="Styles/images/solok.png" width="20px" height="20px" />');

    }, function () {
        $('#divIlanlar2').hide();
        //$('#divIlanBul2').hide();
        $('#bannerBaslik2').hide();
        $
        var r = (($(window).width() - 1250) / 2) - 25;
        if ($(window).width() < 1250) {
            r = 0;
        }
        $('.bannerok2').html('<img  src="Styles/images/sagok.png" width="20px" height="20px" />');
        $("#divBannerEkrani2").animate({ "left": r, "width": 20 }, 1000, "", function () {
            $('.baslikKategori').css("z-index", "99999");
        });

    });

    $("#bannerClik").toggle(function () {
        $('#divIlanlar').show();
        $('#divIlanBul').show();
        $('#bannerBaslik').show();
        var r = (($(window).width() - 1250) / 2) + 1308;
        if ($(window).width() < 1250) {
            r = $(window).width() - 20;
        }
        $("#divBannerEkrani").animate({ "left": r - 400, "width": 400 }, 1000);
        $('.bannerok1').html('<img  src="Styles/images/sagok.png" width="20px" height="20px" />');
    }, function () {
        $('#divIlanlar').hide();
        $('#divIlanBul').hide();
        $('#bannerBaslik').hide();
        var r = (($(window).width() - 1250) / 2) + 1288;
        if ($(window).width() < 1250) {
            r = $(window).width() - 20;
        }
        $('.bannerok1').html('<img  src="Styles/images/solok.png" width="20px" height="20px" />');
        $("#divBannerEkrani").animate({ "left": r, "width": 20 }, 1000);
    });


    ilanListesiGetir();
    yazarListesiGetir();
    $('#txtIlanBul').keypress(function (e) {

        if (e.which == 13) {

            IlanBul();
        }
    });
    $('#yayinAkisi').height($(window).height() - $('#divReklamTv').height() );
    yayinListesiGetir();
    ajaxCalistir({}, "mainFuncs.aspx/reklamZamaniGetir", function (data) {
        reklamDegisimZamani = data.d;
    });
    $('#btnIlanAra').button().click(function () {
        IlanBul();
    });

    videoGetir();
    $('#btnAnaSayfa').click(function () {
        var json = { sparam: "seciliKategori", s: null };
        $.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            url: "mainFuncs.aspx/SessionYaz",
            data: $.toJSON(json),
            dataType: "json",
            success: function (data) {
                window.location = "Default.aspx";
            },
            error: function (xhr, data, textStatus) {

            }
        });

    });
    reklamlariGetir();
    meslekGetir();
    ekranAyarla();
    $('#txtMesaj').ckeditor({ toolbar: 'Custom', //makes all editors use this toolbar
        toolbarStartupExpanded: false,
        toolbarCanCollapse: false,
        toolbar_Custom: ''
    });
    if (ekUploader == null) {
        createEkUploader();
    }
    ekler = "";

    $('#btnKaydet').button().click(function () {
        iletisimKaydet();
    });
    $('#btnAnket').click(function () {
        window.location = "anket.aspx";
    });
    $('#btnIletisim').click(function () {
        window.location = "iletisim.aspx";
    });
    istatistikGetir();
    var az = $('#haberAkis').width() + $('#AnaSayfaSol').width() + 10;
    var yb = $(document).width() * 0.03;
    var b = $('#divReklamlar').height() + $('#counter').height() + 270;
    
    
    $('#yayinAkisi').height($(window).height() - b);


    reklamSayiArttir("y1");
    reklamSayiArttir("y2");
    reklamSayiArttir("t");

});

$(window).resize(function () {

//    $('.fScreen').css("width", $(window).width() - 10);
//    $('.kapla').css("height", $(window).height() - 50);
    ekranAyarla();
    // $('#AnaSayfaSol').tinyscrollbar();


});
$(window).scroll(function () {
   // ekranAyarla();

});
function ekranAyarla() {
    if ($(window).width() > 1250) {
        $('#kontrolPaneli').width($('#fScreen').width() + 85);
        var l = (($(window).width() - 1250) / 2) + 943;
        $('#sagScrl').css("left", l);
        var r = (($(window).width() - 1250) / 2) + 1288 ;
        $('#divBannerEkrani').css("left", r);
        //$('#counter').css("position", "fixed");
        $('#divBannerEkrani2').css("left", (($(window).width() - 1250) / 2) - 25);
    } else {
        $('#kontrolPaneli').width($('#fScreen').width());

        $('#sagScrl').css("position", "static").css("margin-left", 0 + "px").css("float", "left").css("min-width", 300 + "px");
        $('#counter').css("position", "static");
        $('#divBannerEkrani').css("left", $(window).width() - 20);

    }
    $('.AnaSayfaSol').css('top', ($(this).scrollTop() + 22) + "px");
}


function videoGetir() {
    ekranKilitle("Video Yükleniyor");
    var json = {};
    $.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: "mainFuncs.aspx/tvVideoGetir",
        data: $.toJSON(json),
        dataType: "json",
        success: function (data) {
            ekranAc();
            if (data.d != null) {
                videoElementOlustur(data.d)
            }
        },
        error: function (xhr, data, textStatus) {
            ekranAc();
            hataver(xhr, status, Error);
        }
    });
}


function metaAyarla(desc) {
    $('meta[name=Description]').attr('content', desc);
}
function videoOynat(dosya) {
    $("#videoTV").attr("src", "/haberTV/" + dosya);
    var player = new MediaElementPlayer('#videoTV');
    player.pause();
    player.setSrc("/haberTV/" + dosya);
    player.play();


}


var yarim1 = "";
var yarim2 = "";
var tamboy = "";
function reklamlariGetir() {

    var json = {};
    $.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: "mainFuncs.aspx/reklamTanimlariGetir",
        data: $.toJSON(json),
        dataType: "json",
        success: function (data) {
            $('#divReklamlar').html('');


            var i = 0;
            if (data.d != null) {

                var eurl, baslik, fb, gp, tw;
                if (data.d.tamboyAcik == 'T') {
                    eurl = encodeURIComponent('http://' + window.location.host + '/reklamResimleri/t/' + data.d.tamboyresim);
                    baslik = '<div class="fnt solyuzdeyuz" style="font-size:11px;font-weight:bold;margin-top:-28px;">www.sosyalmedyahaber.org</div>';
                    fb = '<div style="float:left;width:100px"><div  id="fbbhltamboy" class="fb-like" data-href="http://' + window.location.host + '"/reklamResimleri/t/' + data.d.tamboyresim + '" data-send="false" data-layout="button_count" data-width="90" data-show-faces="false"></div></div>';
                    fb2 = '<div style="float:left;width:90px"><div  id="fbbhltamboy2" class="fb-like" action="recommend"  data-href="http:/' + window.location.host + '/reklamResimleri/t/' + data.d.tamboyresim + '" data-send="false" data-layout="button_count" data-width="50" data-show-faces="false"></div></div>';
                    var send = '<div style="float:left;width:80px"><div style="width:80px" id="tfbbhl" class="fb-send" data-href="http://' + window.location.host + '/reklamResimleri/t/' + data.d.tamboyresim + '"   data-width="110" data-show-faces="false"></div></div>';
                    //var fb2 = '<div style="float:left;width:210px"><div id="fbbhl2' + value.haberID + '" class="fb-like" data-href="http://'+ window.location.host+'/Default.aspx?hid=' + value.haberID + '" data-send="true" data-layout="button_count" data-width="100" action="recommend" data-show-faces="false"></div></div>';
                    gp = '<div style="float:left;width:50px;margin-left:4px"><g:plusone size="small" href="http://' + window.location.host + '/reklamResimleri/t/' + data.d.tamboyresim + '"></g:plusone></div>';
                    tw = '<iframe allowtransparency="true" frameborder="0"  data-via="sosyalmedyahaber" scrolling="no" data-text="" src="//platform.twitter.com/widgets/tweet_button.html?url=' + eurl + '&text=sosyalmedyahaber.org&lang=tr" style="float:left;width:100px; height:20px;"></iframe>';

                    //                     tamboy = '<div id="tamBoyReklam"  class="tamboyreklam uiListLightblack "><a href="http://' + data.d.tamboylink + '" target="blank"> <img  src="http://' + window.location.host + '/reklamResimleri/t/' + data.d.tamboyresim + '"/></a></div><div style="width:100%;float:left;">' + gp + tw + send + fb + '</div>';
                    tamboy = '<div id="tamBoyReklam"  class="tamboyreklam uiListLightblack "><a href="http://' + data.d.tamboylink + '" target="blank"> <img  src="http://' + window.location.host + '/reklamResimleri/t/' + data.d.tamboyresim + '"/></a></div>';
                    // CreateNewLikeButton2('fbbhltamboy');
                    i = i + 1;
                    tamboyacik = 'T';
                } else {
                    tamboy = '<div class="tamboyreklam">Google Reklami Gelecek</div>';
                    tamboyacik = 'F';
                }

                if (data.d.y1Acik == 'T') {
                    eurl = encodeURIComponent('http://' + window.location.host + '/reklamResimleri/1/' + data.d.yayin1);

                    baslik = '<div class="fnt solyuzdeyuz" style="font-size:11px;font-weight:bold;margin-top:-28px;">www.sosyalmedyahaber.org</div>';
                    fb = '<div style="float:left;width:100px"><div  id="fbbhlyarim1" class="fb-like" data-href="http://' + window.location.host + '/reklamResimleri/1/' + data.d.yayin1 + '" data-send="false" data-layout="button_count" data-width="90" data-show-faces="false"></div></div>';
                    fb2 = '<div style="float:left;width:90px"><div  id="fbbhlyarim1fb2" class="fb-like"  action="recommend"  data-href="http://' + window.location.host + '/reklamResimleri/1/' + data.d.yayin1 + '" data-send="false" data-layout="button_count" data-width="50" data-show-faces="false"></div></div>';
                    //var fb2 = '<div style="float:left;width:210px"><div id="fbbhl2' + value.haberID + '" class="fb-like" data-href="http://' + window.location.host + '/Default.aspx?hid=' + value.haberID + '" data-send="true" data-layout="button_count" data-width="100" action="recommend" data-show-faces="false"></div></div>';
                    gp = '<div style="float:left;width:50px;margin-left:4px"><g:plusone size="small" href="http://' + window.location.host + '/reklamResimleri/1/' + data.d.yayin1 + '"></g:plusone></div> ';
                    tw = '<iframe allowtransparency="true" frameborder="0"  data-via="sosyalmedyahaber" scrolling="no" data-text="" src="//platform.twitter.com/widgets/tweet_button.html?url=' + eurl + '&text=sosyalmedyahaber.org&lang=tr" style="float:left;width:100px; height:20px;"></iframe>';
                    send = '<div style="float:left;width:80px"><div style="width:90px" id="r1fbbhl" class="fb-send" data-href="http://' + window.location.host + '/reklamResimleri/1/' + data.d.yayin1 + '" data-send="false"  data-width="110" data-show-faces="false"></div></div>';

                    //                    yarim1 = '<div id="reklamAlani1" class="reklamAlani1 uiListLightblack"><a href="http://' + data.d.reklamlink1 + '" target="blank"><img  src="http://' + window.location.host + '/reklamResimleri/1/' + data.d.yayin1 + '"/></a></div><div style="width:100%;float:left">' + gp + tw + send + fb + '</div>';
                    yarim1 = '<div id="reklamAlani1" class="reklamAlani1 uiListLightblack"><a href="http://' + data.d.reklamlink1 + '" target="blank"><img  src="http://' + window.location.host + '/reklamResimleri/1/' + data.d.yayin1 + '"/></a></div>';
                    i = i + 1;
                    yarim1acik = 'T';
                    //  CreateNewLikeButton2('fbbhlyarim1');
                } else {
                    yarim1 = '<div class="reklamAlani1">Google Reklami Gelecek</div>';
                    i = i + 1;
                    yarim1acik = 'F';
                }

                if (data.d.y2Acik == 'T') {
                    eurl = encodeURIComponent('http://' + window.location.host + '/reklamResimleri/2/' + data.d.yayin2);
                    baslik = '<div class="fnt solyuzdeyuz" style="font-size:11px;font-weight:bold;margin-top:-28px;">www.sosyalmedyahaber.org</div>';
                    fb = '<div style="float:left;width:100px"><div  id="fbbhlyarim2" class="fb-like" data-href="http://' + window.location.host + '/reklamResimleri/2/' + data.d.yayin2 + '" data-send="false" data-layout="button_count" data-width="90" data-show-faces="false"></div></div>';
                    fb2 = '<div style="float:left;width:90px"><div  id="fbbhlyarim2fb2" class="fb-like" action="recommend" data-href="http://' + window.location.host + '/reklamResimleri/2/' + data.d.yayin2 + '" data-send="false" data-layout="button_count" data-width="50" data-show-faces="false"></div></div>';
                    //var fb2 = '<div style="float:left;width:210px"><div id="fbbhl2' + value.haberID + '" class="fb-like" data-href="http://' + window.location.host + '/Default.aspx?hid=' + value.haberID + '" data-send="true" data-layout="button_count" data-width="100" action="recommend" data-show-faces="false"></div></div>';
                    gp = '<div style="float:left;width:50px;margin-left:4px"><g:plusone size="small" href="http://' + window.location.host + '/reklamResimleri/2/' + data.d.yayin2 + '"></g:plusone></div>';
                    tw = '<iframe allowtransparency="true" frameborder="0"  data-via="sosyalmedyahaber" scrolling="no" data-text="" src="//platform.twitter.com/widgets/tweet_button.html?url=' + eurl + '&text=sosyalmedyahaber.org&lang=tr" style="float:left;width:100px; height:20px;"></iframe>';
                    send = '<div style="float:left;width:80px"><div style="width:80px" id="r2fbbhl" class="fb-send" data-href="http://' + window.location.host + '/reklamResimleri/2/' + data.d.yayin2 + '" data-send="false"  data-width="110" data-show-faces="false"></div></div>';

                    //                    yarim2 = '<div id="reklamAlani2" class="reklamAlani2 uiListLightblack"><a href="http://' + data.d.reklamlink2 + '" target="blank"><img   src="http://' + window.location.host + '/reklamResimleri/2/' + data.d.yayin2 + '"/></a></div><div style="width:100%;float:left">' + gp + tw + send + fb + '</div>';
                    yarim2 = '<div id="reklamAlani2" class="reklamAlani2 uiListLightblack"><a href="http://' + data.d.reklamlink2 + '" target="blank"><img   src="http://' + window.location.host + '/reklamResimleri/2/' + data.d.yayin2 + '"/></a></div>';
                    i = i + 1;
                    yarim2acik = 'T';
                    //  CreateNewLikeButton2('fbbhlyarim2');
                } else {
                    yarim2 = '<div class="reklamAlani2">Google Reklami Gelecek</div>';
                    i = i + 1;
                    yarim2acik = 'F';
                }

                seciliReklam = "y";
                reklamDegistir();
            }


        },
        error: function (xhr, data, textStatus) {
            ekranAc();
            hataver(xhr, status, Error);
        }
    });
}
var seciliReklam = null;
var yarim1acik;
var yarim2acik;
var tamboyacik;
function reklamDegistir() {
    $('#divReklamlar').html('');

    if (seciliReklam == "t") {
        seciliReklam = "y"
    } else {
        seciliReklam = "t";
    }

    if (seciliReklam == "y") {
        $('#divReklamlar').append(yarim1);
        $('#divReklamlar').append(yarim2);
        //        CreateNewLikeButton('fbbhlyarim1');
        //        CreateNewLikeButton('fbbhlyarim1fb2');
        //        CreateNewLikeButton('fbbhlyarim2');
        //        CreateNewLikeButton('fbbhlyarim2fb2');
        if (yarim1acik == 'T') {
            // reklamSayiArttir("y1");

        }
        if (yarim2acik == 'T') {
            //  reklamSayiArttir("y2");
        }
    }

    if (seciliReklam == "t") {
        $('#divReklamlar').append(tamboy);
        //        CreateNewLikeButton('fbbhltamboy');
        //        CreateNewLikeButton('fbbhltamboy2');
        if (tamboyacik == 'T') {
            //   reklamSayiArttir("t");
        }
    }
    // reklamZamanla();
    //seciliReklam = reklamTipi;
    if (reklamDegisimZamani == null) {
        reklamZamanla(5000);
    } else {
        reklamZamanla(reklamDegisimZamani);
    }

    //    var gphtml = '    <script type="text/javascript">    window.___gcfg = { lang: "tr" };    (function () {' +
    //                    'var po = document.createElement("script"); po.type = "text/javascript"; po.async = true;' +
    //                   ' po.src = "https://apis.google.com/js/plusone.js";' +
    //                  '  var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(po, s);' +
    //                   ' })();            </script>';
    //    $('#divReklamlar').append(gphtml);
}
var reklamDegisimZamani = null;
function reklamZamanla(t) {
    setTimeout("reklamDegistir()", t * 1000);
}
function reklamSayiArttir(alanTipi) {
    var json = { alanAdi: alanTipi };
    $.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: "mainFuncs.aspx/reklamSayacArttir",
        data: $.toJSON(json),
        dataType: "json",
        success: function (data) {
        },
        error: function (xhr, data, textStatus) {

        }
    });
}

function videoElementOlustur2(el, isim) {

    if (isim) {
        $('#videoTV').attr("src", "/haberTV/" + isim)
    }


    $('#' + el).mediaelementplayer({
        // if the <video width> is not specified, this is the default
        defaultVideoWidth: 150,
        // if the <video height> is not specified, this is the default
        defaultVideoHeight: 200,
        // if set, overrides <video width>
        videoWidth: -1,
        // if set, overrides <video height>
        videoHeight: -1,
        // width of audio player
        audioWidth: 200,
        // height of audio player
        audioHeight: 30,
        // initial volume when the player starts
        startVolume: 0.8,
        // useful for <audio> player loops
        loop: false,
        // enables Flash and Silverlight to resize to content size
        enableAutosize: false,
        // the order of controls you want on the control bar (and other plugins below)
        features: ['fullscreen', 'progress', 'current', 'duration', 'tracks', 'volume'],

        // automatically selects a <track> element
        startLanguage: '',
        // a list of languages to auto-translate via Google
        translations: [],
        // a dropdownlist of automatic translations
        translationSelector: false,
        // key for tranlsations
        googleApiKey: ''

    });
}

function videoElementOlustur(isim) {

    if (isim) {
        $('#videoTV').attr("src", "/haberTV/" + isim)
    }
    var w = 250;
    var h = $('#tvSabit').height();
    if ($('#haberTV').width() > 339) {
        $('#videoTV').attr("width", $('#haberTV').width() + "px");
        $('#videoTV').attr("height", h + "px");
        w = $('#haberTV').width();
    } else {
        $('#videoTV').attr("width", 340);
    }
    eurl = encodeURIComponent('http://' + window.location.host + '/Default.aspx?tv=' + isim);
    var fb3 = '<div style="float:left;width:60px"><div id="fbteve" class="fb-like" data-href="http://' + window.location.host + '/Default.aspx?tv=' + isim + '" data-send="false" data-layout="button_count" data-width="70"  data-show-faces="false"></div></div>';
    var fb2 = '<div style="float:left;width:105px"><div id="fbteve" class="fb-like" data-href="http://' + window.location.host + '/Default.aspx?tv=' + isim + '" data-send="false" data-layout="button_count" data-width="70" action="recommend" data-show-faces="false"></div></div>';
    var fb = '<div style="float:left;width:60px"><div  id="fbteve2" class="fb-like" data-href="http://www.facebook.com/pages/Sosyal Medya Tv Haber/209184115834750" data-send="false" data-layout="button_count" data-width="50"  data-show-faces="false"></div></div>';
    var gp2 = '<div style="float:left;width:40px"><g:plusone size="small" href="http://' + window.location.host + '/Default.aspx??tv=' + isim + '"></g:plusone></div>';
    var tw = '<iframe allowtransparency="true" frameborder="0"  data-via="sosyalmedyahaber" scrolling="no"  src="//platform.twitter.com/widgets/tweet_button.html?url=' + eurl + '&text= ' + eurl + '&lang=tr" style="float:left;width:65px; height:20px;"></iframe>';

    //$('#fbTvBegen').append(fb2);
    var tw2 = '<div style="float:left;width:110px"> <iframe allowtransparency="true" frameborder="0" scrolling="no" src="//platform.twitter.com/widgets/follow_button.html?screen_name=SosyalMdyaTvHbr&lang=tr" style="width:110px; float:left;height:20px;padding-left:5px"></iframe></div>';
    var send = '<div style="float:left;width:65px"><div style="width:65px"  class="fb-send" data-href="http://' + window.location.host + '/Default.aspx?tv=' + isim + '"   data-width="110" data-show-faces="false"></div></div>';
//    $('#fbTvBegen').append(gp2);
//    $('#fbTvBegen').append(tw2);
//    $('#fbTvBegen').append(tw);
//    $('#fbTvBegen').append(send).append(fb3);
//    CreateNewLikeButton2('fbteve');
//    CreateNewLikeButton2('fbteve2');
    $('#fbTvBegen').append(tw);
    $('#fbTvBegen').append(fb2);
    CreateNewLikeButton2('fbteve');
    //   $('#fbTvBegen').append(fb2);
    //CreateNewLikeButton(window.location.host + 'http://' + window.location.host + '/Default.aspx?tv=' + isim, 'fbTvBegen',1);
    $('#videoTV').mediaelementplayer({

        plugins: ['flash'],
        flashName: 'flashmediaelement.swf',
        defaultVideoWidth: w,
        // if the <video height> is not specified, this is the default
        defaultVideoHeight: h,
        // if set, overrides <video width>
        videoWidth: w,
        // if set, overrides <video height>
        videoHeight: h,
        // width of audio player
        audioWidth: 200,
        // height of audio player
        audioHeight: 30,
        // initial volume when the player starts
        startVolume: 0.0,
        // useful for <audio> player loops
        loop: true,
        pauseOtherPlayers: false,
        // enables Flash and Silverlight to resize to content size
        enableAutosize: false,
        // the order of controls you want on the control bar (and other plugins below)
        features: ['fullscreen', 'volume', 'progress', 'current', 'duration', 'tracks'],

        // automatically selects a <track> element
        startLanguage: '',
        // a list of languages to auto-translate via Google
        translations: [],
        // a dropdownlist of automatic translations
        translationSelector: false,
        // key for tranlsations
        googleApiKey: '',
        success: function (mediaElement, domObject) {
            mediaElement.play();
        }

    });
    $('#videoTV').unbind('click');

}
function yayinListesiGetir() {
    //   ekranKilitle("Yayın Listesi Yükleniyor");
    var json = {};
    $.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: "mainFuncs.aspx/tvYayinListesiGetir",
        data: $.toJSON(json),
        dataType: "json",
        success: function (data) {
            ekranAc();
            $('#yayinAkisi').html('');
            if (data.d != null) {
                $.each(data.d, function (key, value) {
                    var ht = '<div style="float:left;width:98%" id="vid' + value.yayinID + '" class="ui-state-default"><span style="float:left;width:100%" ><span  style="float:left;width:34px">' + value.baslangicSaati + '</span>' + value.programAdi + '</span></div>';
                    $('#yayinAkisi').append(ht);
                    //$('#vid' + value.yayinID).css("cursor", "pointer").click(function () { videoOynat(value.videoDosyasi) });
                })
            }
        },
        error: function (xhr, data, textStatus) {
            ekranAc();
            hataver(xhr, status, Error);
        }
    });
}